<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta content="en" name="language">
	<title>channel</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link media="screen" href="../docutils-api.css" type="text/css" rel="stylesheet">

</head>

<body>

<div class="banner">
<img src="../images/gm-107x76.png" alt="GraphicMagick logo" width="107" height="76" />
<span class="title">GraphicsMagick</span>
<form action="http://www.google.com/search">
  <input type="hidden" name="domains" value="www.graphicsmagick.org" />
  <input type="hidden" name="sitesearch" value="www.graphicsmagick.org" />
<span class="nowrap"><input type="text" name="q" size="25" maxlength="255" />&nbsp;<input type="submit" name="sa" value="Search" /></span>
</form>
</div>


<div class="navmenu">
<ul>
  <li><a href="../index.html">Home</a></li>
  <li><a href="../project.html">Project</a></li>
  <li><a href="../download.html">Download</a></li>
  <li><a href="../README.html">Install</a></li>
  <li><a href="../Hg.html">Source</a></li>
  <li><a href="../NEWS.html">News</a> </li>
  <li><a href="../utilities.html">Utilities</a></li>
  <li><a href="../programming.html">Programming</a></li>
  <li><a href="../reference.html">Reference</a></li>
</ul>
</div>

<main id="channel">
<h1 class="title">channel</h1>
<p class="subtitle" id="image-channel-functions">Image channel functions</p>
<div class="contents topic" id="contents">
<p class="topic-title">Contents</p>
<ul class="simple">
<li><p><a class="reference internal" href="#channelimage" id="id11">ChannelImage</a></p></li>
<li><p><a class="reference internal" href="#exportimagechannel" id="id12">ExportImageChannel</a></p></li>
<li><p><a class="reference internal" href="#getimagechanneldepth" id="id13">GetImageChannelDepth</a></p></li>
<li><p><a class="reference internal" href="#importimagechannel" id="id14">ImportImageChannel</a></p></li>
<li><p><a class="reference internal" href="#importimagechannelsmasked" id="id15">ImportImageChannelsMasked</a></p></li>
<li><p><a class="reference internal" href="#setimagechanneldepth" id="id16">SetImageChannelDepth</a></p></li>
</ul>
</div>
<section id="channelimage">
<h1><a class="toc-backref" href="#id11">ChannelImage</a></h1>
<section id="synopsis">
<h2>Synopsis</h2>
<pre class="literal-block">unsigned int ChannelImage( <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#channeltype">ChannelType</a> channel );</pre>
</section>
<section id="description">
<h2>Description</h2>
<p>Transform an image so that the resulting image is a grayscale image
based on a specified image channel. The resulting image is returned in
the RGB colorspace. This function does not force or assume an input
image colorspace so it may be used to extract channels from images in
colorspaces other than RGB or CMYK. For example, if the image is currently
transformed to the HWB colorspace, the 'B' channel may be extracted by
specifying RedChannel as the ChannelType argument.</p>
<p>The format of the ChannelImage method is:</p>
<pre class="literal-block">unsigned int ChannelImage( <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#channeltype">ChannelType</a> channel );</pre>
<p>A description of each parameter follows:</p>
<dl class="simple">
<dt>image:</dt>
<dd><p>The image.</p>
</dd>
<dt>channel:</dt>
<dd><p>Identify which channel to extract: Red, Cyan, Green, Magenta,
Blue, Yellow, or Opacity.</p>
</dd>
</dl>
</section>
</section>
<section id="exportimagechannel">
<h1><a class="toc-backref" href="#id12">ExportImageChannel</a></h1>
<section id="id1">
<h2>Synopsis</h2>
<pre class="literal-block"><a class="reference external" href="../api/types.html#image">Image</a> *ExportImageChannel( const <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#channeltype">ChannelType</a> channel,
                           <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );</pre>
</section>
<section id="id2">
<h2>Description</h2>
<p>ExportImageChannel() exports a specified image channel as a new image.</p>
<p>The format of the ExportImageChannel method is:</p>
<pre class="literal-block"><a class="reference external" href="../api/types.html#image">Image</a> *ExportImageChannel( const <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#channeltype">ChannelType</a> channel,
                           <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );</pre>
<dl class="simple">
<dt>image:</dt>
<dd><p>The source image.</p>
</dd>
<dt>channel:</dt>
<dd><p>The image channel to export</p>
</dd>
<dt>exception:</dt>
<dd><p>Return any errors or warnings in this structure.</p>
</dd>
</dl>
</section>
</section>
<section id="getimagechanneldepth">
<h1><a class="toc-backref" href="#id13">GetImageChannelDepth</a></h1>
<section id="id3">
<h2>Synopsis</h2>
<pre class="literal-block">unsigned long GetImageChannelDepth( const <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#channeltype">ChannelType</a> channel,
                                    <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );</pre>
</section>
<section id="id4">
<h2>Description</h2>
<p>GetImageChannelDepth() returns the minimum bit depth required to store
the specified image channel without actual loss of color resolution.
Pixel components are stored in a Quantum, which is 8, 16, or 32 bits
depending on the QuantumDepth value set when the software is compiled.
GetImageChannelDepth() returns the smallest modulus storage size which
supports the scale of the pixel within the range (i.e. no information is
lost). As an example, the value one is returned for a bilevel channel
since only one bit of resolution is required to represent a bilevel channel.</p>
<p>The format of the GetImageChannelDepth method is:</p>
<pre class="literal-block">unsigned long GetImageChannelDepth( const <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#channeltype">ChannelType</a> channel,
                                    <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );</pre>
<dl class="simple">
<dt>image:</dt>
<dd><p>The image.</p>
</dd>
<dt>channel:</dt>
<dd><p>Channel to test.</p>
</dd>
<dt>exception:</dt>
<dd><p>Return any errors or warnings in this structure.</p>
</dd>
</dl>
</section>
</section>
<section id="importimagechannel">
<h1><a class="toc-backref" href="#id14">ImportImageChannel</a></h1>
<section id="id5">
<h2>Synopsis</h2>
<pre class="literal-block">MagickPassFail ImportImageChannel( const <a class="reference external" href="../api/types.html#image">Image</a> *source_image, <a class="reference external" href="../api/types.html#image">Image</a> *update_image,
                                   const <a class="reference external" href="../api/types.html#channeltype">ChannelType</a> channel );</pre>
</section>
<section id="id6">
<h2>Description</h2>
<p>ImportImageChannel() imports an image into the specified image channel.</p>
<p>The format of the ImportImageChannel method is:</p>
<pre class="literal-block">MagickPassFail ImportImageChannel( const <a class="reference external" href="../api/types.html#image">Image</a> *source_image, <a class="reference external" href="../api/types.html#image">Image</a> *update_image,
                                   const <a class="reference external" href="../api/types.html#channeltype">ChannelType</a> channel );</pre>
<dl class="simple">
<dt>source_image:</dt>
<dd><p>The image to use as the replacement image channel.</p>
</dd>
<dt>update_image:</dt>
<dd><p>The image to import the channel into.</p>
</dd>
<dt>channel:</dt>
<dd><p>The image channel to import</p>
</dd>
</dl>
</section>
</section>
<section id="importimagechannelsmasked">
<h1><a class="toc-backref" href="#id15">ImportImageChannelsMasked</a></h1>
<section id="id7">
<h2>Synopsis</h2>
<pre class="literal-block">MagickPassFail ImportImageChannelsMasked( const <a class="reference external" href="../api/types.html#image">Image</a> *source_image,
                                          <a class="reference external" href="../api/types.html#image">Image</a> *update_image,
                                          const <a class="reference external" href="../api/types.html#channeltype">ChannelType</a> channels );</pre>
</section>
<section id="id8">
<h2>Description</h2>
<p>ImportImageChannelsMasked() imports all the channels from a source
image to an update image, except for the channels specified.</p>
<p>The format of the ImportImageChannelsMasked method is:</p>
<pre class="literal-block">MagickPassFail ImportImageChannelsMasked( const <a class="reference external" href="../api/types.html#image">Image</a> *source_image,
                                          <a class="reference external" href="../api/types.html#image">Image</a> *update_image,
                                          const <a class="reference external" href="../api/types.html#channeltype">ChannelType</a> channels );</pre>
<dl class="simple">
<dt>source_image:</dt>
<dd><p>The image from which to extract the replacement channels.</p>
</dd>
<dt>update_image:</dt>
<dd><p>The image to import the channels into.</p>
</dd>
<dt>channel:</dt>
<dd><p>The image channel to import</p>
</dd>
</dl>
</section>
</section>
<section id="setimagechanneldepth">
<h1><a class="toc-backref" href="#id16">SetImageChannelDepth</a></h1>
<section id="id9">
<h2>Synopsis</h2>
<pre class="literal-block">MagickPassFail SetImageChannelDepth( <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#channeltype">ChannelType</a> channel,
                                     const unsigned int depth );</pre>
</section>
<section id="id10">
<h2>Description</h2>
<p>SetImageChannelDepth() translates the pixel quantums in the specified
channel so that if they are later divided to fit within the specified bit
depth, that no additional information is lost (i.e. no remainder resulting
from the division). Note that any subsequent image processing is likely
to increase the effective depth of the image channels. A non-zero
value is returned if the operation is successful. Check the exception
member of image to determine the cause for any failure.</p>
<p>The format of the SetImageChannelDepth method is:</p>
<pre class="literal-block">MagickPassFail SetImageChannelDepth( <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#channeltype">ChannelType</a> channel,
                                     const unsigned int depth );</pre>
<dl class="simple">
<dt>image:</dt>
<dd><p>The image to update.</p>
</dd>
<dt>channel:</dt>
<dd><p>Channel to modify.</p>
</dd>
<dt>depth:</dt>
<dd><p>Desired channel depth (range 1 to QuantumDepth)</p>
</dd>
</dl>
</section>
</section>
</main>


<hr class="docutils">
<div class="document">
    <p><a href="../Copyright.html">Copyright</a> © GraphicsMagick Group 2002-2025<!--SPONSOR_LOGO--></p>
</div>

</main>
</body>
</html>
